package src.adiel.bgu;

import org.opencv.android.Utils;
import org.opencv.core.Mat;

import android.graphics.Bitmap;

public class ImageProcess {

	public ImageProcess(){
		
	}
	
	public Bitmap iterateOverABitmap(Bitmap bitmap){
		
		Mat tMat = Utils.bitmapToMat(bitmap);
		double[] tPixel = null;
		for (int i = 0; i < tMat.rows(); i++) {
			for (int j = 0; j < tMat.cols(); j++) {
				tPixel = tMat.get(i, j);
				for (int j2 = 0; j2 < tPixel.length; j2++) {
					if(tPixel[j2] >= 127.0){
						tPixel[j2] = 127.0;
					}
					else{
						tPixel[j2] = 0;
					}
				}
				tMat.put(i, i, tPixel);
				System.out.print(" ");
			}
			System.out.println();
		}
		Utils.matToBitmap(tMat, bitmap);
		return bitmap;
	}
	public native void FindFeatures(long matAddrGr, long matAddrRgba, long resMat);

    static {
        System.loadLibrary("featureDetect");
    }
	
}
